package top.hongthorn.util;

import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class Result<T> {


    private Integer state;


    private String message;


    private T data;

    public Result(Integer state, String message) {
        this.state = state;
        this.message = message;
    }


    public Result() {
    }

    public Result(Integer state, String message, T data) {
        this.state = state;
        this.message = message;
        this.data = data;
    }



    //成功的时候调用
    public static <T> Result<T> success(Integer state, String message, T data) {
        return new Result<T>(state, message, data);
    }

    //失败的时候调用
    public static <T> Result<T> error(Integer state, String message, T data) {
        return new Result<T>(state, message, data);
    }


}
